package com.chinasoft.cr;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;

import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 应用程序的入口点类。
 *
 * @@SpringBootApplication 标注这是一个Spring Boot的自动配置应用。
 * @MapperScan("com.demo.**.mapper") 指定MyBatis映射器接口所在的包。
 */
@SpringBootApplication
@MapperScan("com.chinasoft.cr.mapper")
@Slf4j
public class NewApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(NewApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if (StringUtils.isEmpty(path)) {
            path = "";
        }
        log.info("\n----------------------------------------------------------\n\t" +
                "Application  is running! Access URLs:\n\t" +
                "前端访问网址: \t\thttp://localhost:" + "80" + "\n\t" +
                "代码生成访问网址: \t\thttp://localhost:" + "8888" + "\n\t" +
                "接口文档访问网址: \t\thttp://localhost:"+ port + path+ "/doc.html"+"\n\t" +
                "----------------------------------------------------------");
        String jvmName = ManagementFactory.getRuntimeMXBean().getName();
        log.info("当前项目进程号：" + jvmName.split("@")[0]);
    }

}